var orderComment = -1;
jQuery(function(){
	$("#cancel").click(function(){
		$('.attention_box').addClass('disno1');
		$("#bad").removeClass("bad_sel")
		$("#good").removeClass("good_sel")
		$("#comment").val("");
	});
	$("#sure").click(function(){
		sure();
	});
	$("#good").click(function(){
		if($(this).hasClass("good_sel")){
			orderComment = -1
			$(this).removeClass("good_sel")
			$("#bad").removeClass("bad_sel");
		}else{
			orderComment = 1;
			$(this).addClass("good_sel")
			$("#bad").removeClass("bad_sel")

		}
	});
	$("#bad").click(function(){
		if($(this).hasClass("bad_sel")){
			orderComment = -1
			$("#good").removeClass("good_sel")
			$(this).removeClass("bad_sel")
		}else{
			$(this).addClass("bad_sel");
			$("#good").removeClass("good_sel")
			orderComment = 0
		}
	});
	$("#payCancel").click(function(){
		$("#payNow").addClass("disno1");
		$("#payNow").find("img").attr("src","")
		$("#remark").val("")
	})

	$("#payConfirm").click(function(){
		payMoney();
	});

	doubleClick("img1",function(obj){
		$(obj).attr("src", "");
		$(obj).parent().addClass("disno1");
		$("#filePicker").show()
	})
	doubleClick("img2",function(obj){
		$(obj).attr("src", "");
		$(obj).parent().addClass("disno1");
		$("#filePicker").show()
	})
	var paramMap = params();
	jQuery.ajax({
		url:server_url+"/rest/buyerOrder/getOrderInfo.do",
		data:{orderid:paramMap['orderId']},
		success:function(data){
			if(data.retCode != '0000'){
				easyAlert("出了点问题:-D");
				return;
			}
			var order = data.data;
			console.log(order)
			$("#orderNo").html('订单号：'+order.orderCode+ '<span id="orderStatusName">'+order.orderStatusName+'</span>')
			$("#orderRemark").text("备注："+(order.remark==null?"":order.remark));
			$("#price").text("合计：¥"+order.price)
			$("#total_price").text("¥"+order.price)
			mapIfExist(function(orderDetail){
				$("#productPic").attr("src",orderDetail.productPic);
				$("#productName").text(orderDetail.productName)
				$("#productPrice").text("¥"+orderDetail.productPrice+"/头")
				$("#specName").html('类别： '+orderDetail.spec+'<span id="productNum"><i>X</i>'+orderDetail.productNum+'</span>')
				$("#areaName").text("货源地："+orderDetail.areaName);
			},order.lstOrderDetail);

			if(order.orderStatus == '01'){
				$("#footer").append('<div class="buy" onclick="javascript:cancel('+order.id+','+order.lstOrderDetail[0].supplyProductID+','+order.lstOrderDetail[0].productNum+')">取消订单</div>')
			}
			if(order.orderStatus == '03'){
				$("#footer").append('<div class="buy" onclick="javascript:payNow('+order.id+')">确认付款</div>')
			}
			if(order.orderStatus == '05'){
				$("#footer").append('<div class="buy" onclick="javascript:confirmOrder('+order.id+')">确认收货</div>')
			}
			if(order.orderStatus == '06'){
				$("#footer").append('<div class="buy" onclick="javascript:evaluateOrder('+order.id+')">立即评价</div>')
			}
		},
		erro:function(){
			easyAlert("出了点问题:-D");
		}
	});
	
});
function toBuyerOrder(){
	localStorage.setItem('goOrder',1);
	window.location.href=server_url+"buyer/product/index.do";
}